package com.oocl.myHomework.command;

public class CommandUtil {
	public static String[] COMMANDS = {
		"A","D","H","L","O","U","Q"
	};
	
	
	public static boolean contain(String target){
		boolean result = false;
		for(int i=0 ; i<COMMANDS.length;i++){
			if(COMMANDS[i].equals(target)){
				result = true;
				break;
			}
		}
		return result;
	}
 	
     public static Command  resolveCommand(String input){
    	 Command command = new Command();
    	 String[]  strs = input.split(" ");
    	 if(strs.length==1){
    		 command.setKey(strs[0]);
    		 command.setOprationType(strs[0]);
    	 }else if(strs.length==2){
    		 command.setKey(strs[0]);
    		 command.setOprationType(strs[0]+"1");
    		 command.setValue(strs[1]);
    	 }else if(strs.length==3){
    		 command.setKey(strs[0]);
    		 command.setOprationType(strs[0]+"2");
    		 command.setValue(strs[1]+" "+strs[2]);
    	 }
    	 
    	 return command;
     }
}
